<#include "../header.html">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
	function  renderDetailImg(imgId, imgSrc, fileUrl) {
		var src = "<img src='" + fileUrl +"' srcImg='" + imgSrc +"'style='width:20%;height: 200px;'/>";
		$("#detailImg").append(src);
		$("#detailImg img").unbind();
		bindEvent();
	}
	function alertUsers() {
		JFT.popupPage("userAction.do?method=queryUserAlert", "选择用户", 800, 800);
	}
	function bindEvent() {
		$('#detailImg img').dblclick(function(){
			var delImgSrcHtml = $("#saveImgSrc").val();
			$("#delImgSrc").val(delImgSrcHtml+";"+$(this).attr("srcImg"));
			$(this).remove();
		});
	}
	function assembleData() {
		var imgArr = $('#detailImg img');
		if(imgArr!=null && imgArr.length>0){
			var saveImgSrcHtml = "";
			for(var i=0 ;i<imgArr.length;i++){
				var img = imgArr[i];
				saveImgSrcHtml = saveImgSrcHtml+";"+$(img).attr("srcImg");
			}
			$("#saveImgSrc").val(saveImgSrcHtml);

		}
		return true;
	}

</script>
<div class="c_nav">
	<span>管理选项：</span>
	<a href="momentAction.do?method=query">管理首页</a>
	<a href="javascript:location.reload()"> | [刷新页面]</a>
</div>
<div class="c_box bg_white">
<form id="addForm" name="addForm" action="momentAction.do?method=save" method="post">
	<div class="c_topic"><#if moment.id??>修改<#else>新增</#if>骉圈</div>
	<input type="hidden" name="momentId" id="momentId" value="${moment.id!}"/>
	<input type="hidden" name="delImgSrc" id="delImgSrc" value=""/>
	<input type="hidden" name="saveImgSrc" id="saveImgSrc" value=""/>
	<div class="c_form_3 c_form-label-8">
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">用户名：</span>
			<span class="e_input">
				<input type="text" name="userName" id="userName" desc="用户名" readonly="readonly" <#if moment.id??> <#else> onclick="alertUsers()" </#if> nullable="no" maxlen="100" maxlength="100"   value="${moment.userName!}" />
				<input type="hidden" name="userId" id="userId" desc="用户ID" nullable="no" value="${moment.userId!}"/>
			</span>
		</li>
		<li>
			<span class="e_label e_label-required">状态：</span>
			<span class="e_select">
				<select id="status" name="status" desc="状态" nullable="no">
					<option value="0" <#if moment.status?? && moment.status?string=='0'>selected="selected"</#if>>开放</option>
					<option value="1" <#if moment.status?? && moment.status?string=='1'>selected="selected"</#if>>隐藏</option>
				</select>
			</span>
		</li>
	</ul>
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">引语：</span>
			<span class="e_textarea">
				<textarea name="preface" id="preface" maxlen="255" maxlength="255" nullable="no" placeholder="引语">${moment.preface!}</textarea>
			</span>
		</li>
	</ul>
	</div>
	<div class="c_table">
		<table>
			<tr>
				<td class="label">图片：</td>
				<td>
					<ul class="c_form_6">
						<li>
							<span class="e_input-file-btn ">
								<button type="button" id="uploadBtn" class="e_btn">上传图片</button>
							</span>
						</li>
						<li class="e_red l_ml">建议图片大小720*720(双击图片删除)</li>
					</ul>
					<ul>
						<li>
							<div class="e_textarea " id="detailImg">
								${moment.detailImgHtml!}
							</div>
						</li>
					</ul>
				</td>
			</tr>
		</table>
	</div>
	<div class="e_center" >
		<button type="button" bind="" bindForm="addForm" tradeAction="assembleData()" class="e_btn-page">提交</button>
		<button type="reset" class="e_btn l_ml">重置</button>
	</div>
</form>
</div>
<iframe id="uploadFrame" name="uploadFrame" src="momentAction.do?method=uploadFile&resultCode=-1" frameborder="0" class="e_hide"></iframe>
<script type="text/javascript">
$(function(){
	$("#uploadBtn").click(function(){
		var imgArr = $('#detailImg img');
		if(imgArr!=null && imgArr.length>=9){
			alert("一个骉圈最多9张图片");
		}else{
			$("#imgFile", window.uploadFrame.document).trigger("click");
		}
	});
	bindEvent();
});
</script>
<#include "../footer.html">